package com.ruoyi.web.controller.common;

import com.ruoyi.common.vo.SpuPartnerResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.client.PartnerClient;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.vo.PartnerResponse;

import javax.annotation.Resource;


/**
 * 合作者接口
 * 
 * @author zhoudong
 */
@RestController
@RequestMapping("/partner")
public class PartnerController extends BaseController {
    private static final Logger log = LoggerFactory.getLogger(PartnerController.class);

    @Resource
    private PartnerClient partnerClient;

    /**
     * 获取合作者
     * 
     */
    @GetMapping("/loadAllPartners")
    public AjaxResult loadAllPartners(@RequestParam(required = false) String name) {
        log.info("获取合作者，name:{}", name);
        PartnerResponse partnerResponse = partnerClient.loadAllPartners(name);
        return success(partnerResponse.getData());
    }

    /**
     * 获取SPU合作者
     *
     */
    @GetMapping("/loadAllSpuPartners")
    public AjaxResult loadAllSpuPartners(@RequestParam(required = false) String name) {
        log.info("获取合作者，name:{}", name);
        SpuPartnerResponse partnerResponse = partnerClient.loadAllSpuPartners(name);



        return success(partnerResponse.getData());
    }
}
